<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>设备管理</title> 
{{>/WEB-INF/pages/common/meta_base.part.html}}
{{>/WEB-INF/pages/common/refs_base.part.html}}
{{>/WEB-INF/pages/common/refs_modal.part.html}}
<style>
</style>
<script type="text/javascript">
	function sendMDM(device, code, name, appid) {
		var url = "{{ctx}}/mam/device/sendmdm?deviceId=" + device + "&code="
				+ code + "&name=" + name + "&appId=" + appid;
		$.ajax({
			url : url,
			type : 'post',
			success : function(result) {
				//alert("MDM设备控制命令发送成功!")
				$('#myModal').modal('show')

			},
			error : function() {
				alert(result);
			}
		});
	}
	function checkOs(osName) {
		if (osName == "IOS") {
			$('.divicehide').hide();
			$('.divider').hide();
		} else {
			$('.divicehide').show();
			$('.divider').show();
		}
	}
	function sendM(appId, deviceId) {

		$('#pushMessageTarget').text(deviceId);
		$('#appid').text(appId);
		$('#pushMessageContent').val("");
		$('#sendMessage').modal('show');
	}
	
	function cleardata() {
		$('#pushMessageContent').val("");
	}

	function pushMessage(deviceid, appid) {
		var deviceid = $('#pushMessageTarget').text();
		var appid = $('#appid').text();
		var pushMessageContent = $('#pushMessageContent').val();
        if(!pushMessageContent||pushMessageContent == ""){
            bootbox.alert("内容不能为空!");
            return;
        }
        //长度验证
        var inputNum = $('#pushMessageContent').val().length;
	     if (inputNum > 50) {
	    	 bootbox.alert("内容不能超过50个字符!");
	         return;
	     }
		var url = "{{ctx}}/mam/device/sendmessage?deviceId=" + deviceid
				+ "&pushMessageContent=" + encodeURIComponent(pushMessageContent) + "&appId="
				+ appid;
		$.ajax({
			url : url,
			type : 'post',
			success : function(result) {
				//alert("发送成功!")
				$('#sendMessage').modal('hide');
				$('#myModal').modal('show')
				$('#pushMessageContent').val("");
			},
			error : function(result) {
				alert(result);
			}

		});

	}
</script>
<style type="text/css">
  .a_nav{
    text-decoration: none;
	color: black ;
  }
</style>

</head>

<body>
	{{>/WEB-INF/pages/common/layout_header.part.html}}
	<div class="container">
		<ul class="breadcrumb">
		  <li><a href="{{ctx}}">首页</a></li>
		  <li class="active">设备管理</li>
		</ul>
		<hr class="hr1">
		<div class="hr-10"></div>
		<div class="hr-10"></div>
		<div class="hr-10"></div>
		<div class="row bg-ga">
			<div class="col-sm-2 left_tab">
				<ul>
					<li class="leff_tab_choose">设备管理</li>
					<li class="menu-choose"><a class = "a_nav"
						href="{{ctx}}/mam/device/showdevice">设备管理</a></li>
					<li><a class = "a_nav" href="{{ctx}}/mam/devicescence/showdevicescence">场景控制</a></li>
				</ul>
			</div>
			<div class="pull-left col-sm-10 right_tab">
				<div class="bg_green2-w">
					<div class="intro">设备管理</div>
				</div>
				<div class="hr-10"></div>
				<div class="hr"></div>
				<div style="margin:5px 20px 10px">
<form id="search-form" class="form-inline" role="form" action="{{queryPath}}" method="get">
	<div class="form-group">
		<label class="sr-only">App Id</label>
		<select class="form-control" name="q_EQ_appId">
			{{#apps}}
			<option value="{{key}}" {{#selected}}selected{{/selected}}>{{value}}</option>
			{{/apps}}
		</select>
	</div>
	<div class="form-group">
		<label class="sr-only" for="so_queryFields">查找字段</label>
		<select id="so_queryFields" name="queryField" style="min-width:120px">
		{{#queryFields}}
			<option value="{{key}}" {{#selected}}selected{{/selected}}>{{value}}</option>
		{{/queryFields}}
		</select>
	</div>
	<div class="form-group">
		<label class="sr-only" for="so_queryValue">查找内容</label>
		<div class="input-group" style="width:300px">
    		<input type="text" id="so_queryValue" name="queryValue" value="{{queryValue}}" class="form-control"/>
			<input type="hidden" id="so_dynamicFilter"/>
    		<span class="input-group-btn">
				<button id="so_go" class="btn btn-default" type="submit"><span class="glyphicon glyphicon-search"></span>查找</button>
			</span>
		</div>
	</div>
	<div class="form-group">
		<label class="sr-only">排序</label>
		<div class="btn-group">
		{{#sortInfo}}
		  <button type="button" class="btn btn-info btn-default dropdown-toggle" data-toggle="dropdown">
		    排序：{{currentSortEntry.text}}
		    {{^noneSortEntry}}
			    {{#currentSortEntry.asc}}↑{{/currentSortEntry.asc}}
			    {{^currentSortEntry.asc}}↓{{/currentSortEntry.asc}}
		    {{/noneSortEntry}}
		    <span class="caret"></span>
		  </button>
		  <ul class="dropdown-menu" role="menu">
		  	{{#sortEntrys}}
		    <li>
		    	<a href="?st_{{name}}={{nextDir}}{{#filterExp}}&{{filterExp}}{{/filterExp}}">
		    	{{text}} 
		    	{{#selected}}
			    	{{#nextAsc}}↑{{/nextAsc}}
			    	{{^nextAsc}}↓{{/nextAsc}}
		    	{{/selected}}
		    	</a>
		    </li>
		    {{/sortEntrys}}
		  </ul>
		{{/sortInfo}}
		</div>
	</div>
	{{#otherParams}}
	<input type="hidden" name="{{key}}" value="{{value}}"/>
	{{/otherParams}}
</form>
<script type="text/javascript">
	$(document).ready(function() {
	   	var txtDynamicFilter=$("#so_dynamicFilter"),
	   		selQueryField=$("#so_queryFields")
	   		txtQueryValue=$("#so_queryValue");
	   	selQueryField.on("change", function(evt){
			 var name=$(this).children('option:selected').val();
			 txtDynamicFilter.attr('name',name);
			 txtDynamicFilter.val(txtQueryValue.val());
		});
	   	$('#so_go').on("click", function(evt){
	   		var name=selQueryField.children('option:selected').val();
	   		txtDynamicFilter.attr('name', name);
	   		txtDynamicFilter.val(txtQueryValue.val());
	   	});
	   	selQueryField.trigger("change");
	});
</script>					
			    </div>
				<div class="table-responsive">
					<table class="table table-bordered table-center table-hover">
						<thead>
							<style>
							.title th,.table td {
								text-align: center;
							}
							</style>
							<tr class="title title10"
								style="background-color: rgb(248, 248, 248);">
								<th class="bd_txt2 bd_le">设备名/设备ID</th>
								<th class="bd_txt2 bd_le">应用名</th>
								<th class="bd_txt2 bd_le">系统/版本</th>
								<th class="bd_txt2 bd_le">用户名</th>
								<th class="bd_txt2 bd_le">标签</th>
								<th class="bd_txt2 bd_le">操作</th>
							</tr>
						</thead>
						<tbody>
							{{#list}}
							<tr style="background-color: rgb(255, 255, 255);">
								<input type="hidden" id="appid" value={{appId}}>
								<td class="bd_txt3">
									<h4 data-toggle="tooltip" title="最近签到时间:{{checkinTime}}">{{deviceName}}</h4>
									<small>{{deviceId}}</small>
								</td>
								<td class="bd_txt3">{{bslAppName}}</td>
								<td class="bd_txt3">{{osName}}&nbsp;{{osVersion}}</td>
								<td class="bd_txt3">{{alias}}</td>
								<td class="bd_txt3">
									{{#categoryTags}}
									<div class="form-inline">
										<span class="label label-info" style="line-height:25px;">{{key}}</span>
										{{#values}}
										<span class="label label-success" style="line-height:25px;">{{.}}</span>
										{{/values}}
									</div>
									{{/categoryTags}}
								</td>
								<td class="bd_txt3">
									<div class="btn-group">
	     							<button type="button" class="btn btn-primary dropdown-toggle" onclick="checkOs('{{osName}}')" data-toggle="dropdown"><span class="caret"></span></button>
									<ul id="menu3" class="dropdown-menu" role="menu" aria-labelledby="btnGroupDrop1">
										<li role="presentation"><a role="menuitem" tabindex="-1" onclick="sendM('{{appId}}','{{deviceId}}')"
											>发送系统信息</a></li>
										<li class="divider"></li>
										{{#deviceScenceList}}
										<li role="presentation" class ="divicehide" ><a role="menuitem" tabindex="-1" 
											onclick="sendMDM('{{deviceId}}','{{code}}','{{name}}','{{appId}}')">{{name}}</a>
											</li>
										{{/deviceScenceList}}
									</ul> 
									</div>
								</td>
							</tr>
							{{/list}}
						</tbody>
					</table>
					{{#page}} {{>/WEB-INF/pages/common/pagination.part.html}} {{/page}}
				</div>
			</div>
		</div>
		{{>/WEB-INF/pages/device/device-modal.html}}
	</div>

	{{>/WEB-INF/pages/common/layout_footer.part.html}}
</body>
</html>
